﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Commerce/Views/Shared/Backend.Master"
    Inherits="System.Web.Mvc.ViewPage<ICustomer>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <%:"Edit Customer".Localize()%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h3 class="title">
        <%: "Edit Customer:".Localize()%>(<%: this.Model.Id %>)
        <a id="back-to-list" href="<%: this.ViewData["ReturnUrl"] %>">back to list</a>
       </h3>
    <div class="tabs">
        <ul class="clearfix">
            <li class="current"><a class="tab-link" href="#profile">
                <%:"Profile".Localize() %></a></li>
            <li><a class="tab-link" href="#password">
                <%:"Change password".Localize() %></a></li>
            <li><a class="tab-link" href="#addresses">
                <%:"Address list".Localize() %></a></li>
            <li><a class="tab-link" href="#orders">
                <%:"Order list".Localize() %></a></li>
        </ul>
    </div>
    <div class="tab-content" id="profile">
        <%: Html.EditorForModel() %>
    </div>
    <div class="tab-content hide" id="password">
        <div class="common-form password-form">
            <form action='<%= ViewData["change_password_action"] %>' method="post">
            <%: Html.HiddenFor(i=>i.Id) %>
            <fieldset>
                <table>
                    <tbody>
                        
                        <tr>
                            <th>
                                <label>
                                    <%: "New password".Localize() %></label>
                            </th>
                            <td>
                                <input type="password" name="newPassword" />
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%: "New password confirmation".Localize()%></label>
                            </th>
                            <td>
                                <input type="password" name="reNewPassword" />
                            </td>
                        </tr>
                    </tbody>
                </table>
            </fieldset>
            <div class="buttons">
                <button type="submit">
                    <%:"Save".Localize() %></button>
            </div>
            </form>
        </div>
    </div>
    <div class="tab-content hide" id="addresses">
        <div class="table-container">
            <table>
                <caption>
                    <%:"Address".Localize() %><a href="#address-form" class="o-icon add address-add"><%:"Add".Localize() %></a></caption>
                <thead>
                    <tr>
                        <th>
                            <%:"Address".Localize() %>
                        </th>
                        <th class="action">
                            <%:"Edit".Localize() %>
                        </th>
                        <th class="action">
                            <%:"Delete".Localize() %>
                        </th>
                    </tr>
                </thead>
                <tbody id="address-container">
                </tbody>
            </table>
        </div>
    </div>
    <div class="dialog" id="address-form-dialog" title="<%:"Add address".Localize() %>" style=" height:500px; width:650px;">
        <div class="common-form">
            <div class="hide message-box error">
                <p>
                </p>
            </div>
            <div class="hide message-box info">
                <p>
                </p>
            </div>
            <form method="post" action="#" id="address-form">
            <%: Html.Hidden("CustomerId",this.Model.Id) %>
            <input type="hidden" name="Id" />
            <fieldset>
                <legend>
                    <%:"Add address".Localize()%></legend>
                <table>
                    <tbody>
                        <tr>
                            <th>
                                <label>
                                    <%:"First name".Localize() %></label>
                            </th>
                            <td>
                                <input type="text" name="FirstName" class="medium" />
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%:"Last name".Localize() %></label>
                            </th>
                            <td>
                                <input type="text" name="LastName" class="medium" />
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%:"Address1".Localize() %></label>
                            </th>
                            <td>
                                <input type="text" name="Address1" class="medium" />
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%:"Address2".Localize() %></label>
                            </th>
                            <td>
                                <input type="text" name="Address2" class="medium" />
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%:"Country".Localize() %></label>
                            </th>
                            <td>
                                <%: Html.DropDownList("Country.CountryCode", ViewData["Countries"] as SelectableList, new { @class="medium" })%>
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%:"State".Localize() %></label>
                            </th>
                            <td>
                                <input type="text" name="State" class="medium" />
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%:"City".Localize() %></label>
                            </th>
                            <td>
                                <input type="text" name="City" class="medium" />
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%:"Postcode".Localize() %></label>
                            </th>
                            <td>
                                <input type="text" name="Postcode" class="medium" />
                            </td>
                        </tr>
                        <tr>
                            <th>
                                <label>
                                    <%:"Phone number".Localize()%></label>
                            </th>
                            <td>
                                <input type="text" name="Phone" class="medium" />
                            </td>
                        </tr>
                    </tbody>
                </table>
            </fieldset>
            <div class="buttons">
                <input type="submit" class="button" value="Save" /><a class="button cancel" href="#"><%:"Cancel".Localize() %></a>
            </div>
            </form>
        </div>
    </div>
    <table id="address-row" class="hide">
        <tbody>
            <tr class="template">
                <td>
                    <span class="Address2"></span><span class="Address1"></span><span class="Postcode">
                    </span><span class="City"></span><span class="State"></span><span class="CountryName">
                    </span><span class="FirstName"></span><span class="LastName"></span><span class="Phone">
                    </span>
                    <input type="hidden" name="CountryCode" />
                </td>
                <td class="action">
                    <a href="#address-form" class="o-icon edit" title="Edit">
                        <%:"Edit".Localize() %></a>
                </td>
                <td class="action">
                    <form class="address-delete-form" action='<%= ViewData["address_delete_action"] %>'
                    method="post">
                    <a href="#" class="o-icon delete delete-link" message='<%= "Are you sure you want to delete this address?".Localize() %>'
                        title="Delete">
                        <%:"Delete".Localize() %></a>
                    <input type="hidden" name="Id" value='-1' />
                    <input type="hidden" name="CustomerId" value='<%= this.Model.Id %>' />
                    </form>
                </td>
            </tr>
        </tbody>
    </table>
    <div class="tab-content hide" id="orders">
        <div class="command clearfix">
            <a class="button" href='<%=  ViewData["order_add_action"] %>'>
                <%: "Create new Order".Localize()%></a>
        </div>
        <div class="table-container">
            <table>
                <thead>
                    <tr>
                        <th>
                            <%:"Order ID".Localize() %>
                        </th>
                        <th class="numeral">
                            <%:"Quantity".Localize() %>
                        </th>
                        <th class="numeral">
                            <%:"Total".Localize() %>
                        </th>
                        <th>
                            <%:"Order date".Localize() %>
                        </th>
                        <th>
                            <%:"Status".Localize() %>
                        </th>
                        <th class="action">
                            <%:"View".Localize() %>
                        </th>
                    </tr>
                </thead>
                <tbody id="order-container">
                </tbody>
            </table>
            <div class="pagination">
                <div>
                </div>
            </div>
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MenuContent" runat="server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="WidgetContent" runat="server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="ScriptContent" runat="server">
    <script type="text/javascript">
    var PageCount = <%= ViewData["PageCount"] %>;
    var Orders = <%= ViewData["Orders"] %>;
    var CurrentPageIndex = 1;
    var OrdersUrl = '<%= Url.Action("orders")%>';
    //var OrderDetailUrl = '<%= Url.Action("detail","Order") %>';

    var address_list = <%= ViewData["addresslist"]%>;

    var address_add_action = '<%= ViewData["address_add_action"] %>';
    var address_update_action = '<%= ViewData["address_update_action"] %>';
    var address_delete_action = '<%= ViewData["address_delete_action"] %>';

    </script>
    <%using (var loader = ClientLoader.RegisterInstance())
      {
          loader.Run(ViewData["address_validator"] as string);
          loader.Run(ViewData["customer_validator"] as string);
          loader.Require("customer.edit.js");
      } %>
</asp:Content>
